package com.hbun.cxcy.controller;


import com.hbun.cxcy.common.utils.R;
import com.hbun.cxcy.entity.File;
import com.hbun.cxcy.entity.Swiper;
import com.hbun.cxcy.service.SwiperService;
import com.hbun.cxcy.vo.FileVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mahaunyu
 * @since 2022-01-27
 */
@CrossOrigin
@RestController
@RequestMapping("/cxcy/swiper")
public class SwiperController {
    @Autowired
    SwiperService swiperService;
    @GetMapping("/list")
    public R list(){
        List<File> list = swiperService.listByCustom();
        return R.ok().put("data",list);
    }

    @PostMapping("/save")
    public R save(@RequestBody FileVo fileVo){
        swiperService.saveWithCustom(fileVo);
        return R.ok();
    }


    @RequestMapping("/delete")
    //@RequiresPermissions("cxcyweb:dept:delete")
    public R delete(@RequestBody Long[] deptIds){
        System.out.println(Arrays.toString(deptIds));
        swiperService.removeByIdsWithCustom(Arrays.asList(deptIds));
//        deptService.removeById(deptIds);
        return R.ok();
    }
}

